<?php

/**
 * MVM_MALL 网上商店系统  后台邮件发送
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-02-27 $
 * $Id: sendmail.inc.php www.mvmmall.com$
 * ---------------------------------------------
*/

if(!defined('MVMMALL') || !defined('IN_ADMINCP')) exit('Access Denied');
if($action=='add'){
	if ($_POST && $setp==1) {
		
		if ($send_type==1) {
			include_once template('email_send');
			$mail_content = clean_html('get'); 
			$goods_grant = (int)$goods_grant;
			$sql  = $goods_grant>0 ? "SELECT member_email,member_class FROM `{$tablepre}member_table` WHERE member_class='$goods_grant'":"SELECT member_email,member_class FROM `{$tablepre}member_table`";
			$result = $db->query($sql);
			while ($rt=$db->fetch_array($result)) {
				if($rt['member_email']){
					$i++;
					if (smtp_mail($rt['member_email'],$mailer_subject,$mailer_body)){
						echo "&nbsp;$rt[member_email]&nbsp;&nbsp;$i Send successfully....<br>";
					} else {
						$j++;
						echo "&nbsp;$rt[member_email]&nbsp;&nbsp;$j Send failed....<br>";
					}
				}
			}
		}else {
			if (smtp_mail($receivers,$mailer_subject,$mailer_body)){
				echo "&nbsp;$receivers&nbsp;&nbsp; Send successfully....<br>";
			} else {
				echo "&nbsp;$receivers&nbsp;&nbsp; Send failed....<br>";
			}
		}
	}else {
		$arr = $cache->get_cache('grade');
		$arr[0]='All';
		$grant_menu   = drop_menu($arr,'goods_grant');
		require_once template('sendmail');
		footer();
	}
}